﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace LetiLib.Connection
{
    /*
 * Send data format:
 *    - <server tag> <command> <length - optional> <data>
 *    <server tag>: 0x01
 *    <control command>:
 *        - UPDATE: 0x10 + <length> <data>
 *        - SET_BRIGHT: 0x11 + <4 byte data>
 *        - GET_BRIGHT: 0x12
 *        - CHECK_LED: 0x13
 *        - SET_PASSWORD: 0x14 : <length> <data>
 *        - GET_PASSWORD: 0x15
 *        
 *    <communicate command>
 *        - PING: 0x20
 *        - ACK: 0x20
 *        - NACK: 0x21
 *        - ERROR_1: 0x22
 *        - ERROR_2: 0x23
 *        ....
 */

/*
    * Received data format:
    *    - <Device tag> <command> <length> <data>
    *    <Device tag>: 0x02
    *    <command>:
    *        - UPDATE: 0x10
    *        - SET_BRIGHT: 0x11
    *        - GET_BRIGHT: 0x12
    *        - CHECK_LED: 0x13
    *        
    */

    public enum TAG
    {
        SERVER_TAG = 0x00,
        DEVICE_TAG,

        // commands server sent to device
        GET_VERSION = 0x10,
        SET_VERSION,
        GET_PASSWORD,
        SET_PASSWORD,
        GET_BRIGHTNESS,
        SET_BRIGHTNESS,
        CHECKLED,

        // Bitmap data update command
        CMD_SERVER_DATA_UPDATE_REQ,
        RES_DATA_UPDATE_REQUEST_OK,
        RES_DATA_UPDATE_REQUEST_ERROR,
        DATA_INFO_HEADER,
        RES_DATA_INFO_SENDING,
        RES_DATA_INFO_RECEIVED,
        DATA_PACKAGE_HEADER,

        DATA_PACKAGE_LENGTH = 1024,
        RES_DATA_PACKAGE_SENDING = DATA_PACKAGE_HEADER + 1,
        RES_DATA_PACKAGE_RECEIVED,
        RES_DATA_PACKAGE_ERROR_CHECKSUM,
        RES_DATA_PACKAGE_ERROR_PACKAGEID,

        // Playlist Bitmap data update command
        CMD_SERVER_PLAYLIST_UPDATE_REQ,
        RES_PLAYLIST_UPDATE_REQUEST_OK,
        RES_PLAYLIST_UPDATE_REQUEST_ERROR,
        PLAYLIST_INFO_HEADER,
        RES_PLAYLIST_INFO_SENDING,
        RES_PLAYLIST_INFO_RECEIVED,


        // FIRMWARE update command
        CMD_SERVER_FIRMWARE_UPDATE_REQ = 0x50,
        RES_FIRMWARE_UPDATE_REQUEST_OK,
        RES_FIRMWARE_UPDATE_REQUEST_ERROR,
        RES_FIRMWARE_UPDATE_REQUEST_LASTEST,
        FIRMWARE_INFO_HEADER,
        RES_FIRMWARE_INFO_SENDING,
        RES_FIRMWARE_INFO_RECEIVED,
        FIRMWARE_PACKAGE_HEADER,
        FIRMWARE_PACKAGE_LENGTH = 1000,
        RES_FIRMWARE_PACKAGE_SENDING = FIRMWARE_PACKAGE_HEADER+1,
        RES_FIRMWARE_PACKAGE_RECEIVED,
        RES_FIRMWARE_PACKAGE_ERROR_CHECKSUM,
        RES_FIRMWARE_PACKAGE_ERROR_PACKAGEID,

        // Device commands sent back to server
        CMD_BLACKBOX_DATALOG,
        CMD_IMEI_REQUEST,
        
        CMD_INSERT_IMAGE = 0x70,
        CMD_UPDATE_IMAGE,
        CMD_DELETE_IMAGE,
        CMD_DELETE_ALL_IMAGE,
        CMD_GET_LIST_IMAGE_INDEX,

        CMD_CREATE_PAGE = 0xA0,
        CMD_UPDATE_PAGE,
        CMD_DELETE_PAGE,
        CMD_GET_PAGE_INFO,
        RES_GET_PAGE_INFO,
        CMD_SET_ACTIVE_PAGE,
        CMD_GET_ACTIVE_PAGE,
        RES_GET_ACTIVE_PAGE,

        CMD_INSERT_POPUP,
        CMD_UPDATE_POPUP,
        CMD_DELETE_POPUP,

        CMD_INSERT_IMAGE_TO_PLAYLIST,
        CMD_UPDATE_IMAGE_TO_PLAYLIST,
        CMD_DELETE_IMAGE_FROM_PLAYLIST,
        
        CMD_UPDATE_BUS_DATA,

        PING = 0x30,
        ACK,
        NACK,
        WARNING_TOO_HOT,
        WARNING_DAMAGED,
        WARNING_OUT_OF_POWER,
        WARNING_OPENNED,
        SUCCESS,
        FAILED,
        ERROR_1,// TBD
    }
}
